import * as types from '../types';
import axios from 'axios';

export default {
  state: {
    apps: 0,
    devices: 0,
    totaldown: 0,
    totalup: 0
  },
  mutations: {
    [types.SET_GENERAL]: (state, payload) => {
      state.apps = payload.apps;
      state.devices = payload.devices;
      state.totalup = payload.totalup;
      state.totaldown = payload.totaldown;
    },
  },
  actions: {
    get_general: ({ commit }) => {
      axios.get("/general/").then(response => {
        commit(types.SET_GENERAL, response.data);
      }).catch(err => {
        console.log(err);
      });
    }
  }
}